package org.xm.sk.vo.tb;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.xm.sk.vo.Base;
import org.xm.sk.vo.e.CouponStatus;

import com.fasterxml.jackson.annotation.JsonIgnore;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

@Entity
@Getter
@Setter
@Table(name = "dc_coupon")
@ApiModel(value = "Coupon", parent = Base.class, description = "优惠券")
public class Coupon extends Base {

    /**
     * 
     */
    private static final long serialVersionUID = -1520188792758112378L;

    @ApiModelProperty(value = "优惠券名称")
    @Column(length = 255)
    private String name;
    
    @ApiModelProperty(value = "优惠券所属门店ID")
    @Transient
    private Integer shopId;

    @ApiModelProperty(value = "优惠券所属门店名称")
    @Column(length = 255)
    private String shopName;
    
    @ApiModelProperty(value = "优惠券所属发型师ID")
    @Transient
    private Integer hairdresserId;

    @ApiModelProperty(value = "优惠券所属发型师名称")
    @Column(length = 255)
    private String hairdresserName;
    
    @ApiModelProperty(value = "优惠券所属客户ID")
    @Transient
    private Integer userId;

    @ApiModelProperty(value = "优惠券所属客户名称")
    @Column(length = 255)
    private String userName;

    @ApiModelProperty(value = "优惠券号")
    @Column(length = 255)
    private String couponnum;

    @ApiModelProperty(value = "优惠券使用状态")
    @Enumerated(value = EnumType.ORDINAL)
    @Column
    private CouponStatus status;

    @ApiModelProperty(value = "优惠券所属活动Id")
    @Transient
    private Integer activityId;

    @ApiModelProperty(value = "优惠券所属活动名称")
    @Transient
    private String activityName;
    
    @ApiModelProperty(value = "优惠券所属活动")
    @JsonIgnore
    @ManyToOne(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY)
    @JoinColumn(name = "dc_activity_id")
    private Activity activity;

    @ApiModelProperty(value = "优惠券所属发型师")
    @JsonIgnore
    @ManyToOne(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY)
    @JoinColumn(name = "dc_hairdresser_id")
    private Hairdresser hairdresser;

    @ApiModelProperty(value = "优惠券所属门店")
    @JsonIgnore
    @ManyToOne(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY)
    @JoinColumn(name = "dc_shop_id")
    private Shop shop;

    @ApiModelProperty(value = "优惠券所属客户")
    @JsonIgnore
    @ManyToOne(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY)
    @JoinColumn(name = "dc_user_id")
    private User user;

    @ApiModelProperty(value = "优惠券使用订单")
    @JsonIgnore
    @OneToOne(cascade = {
            CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "coupon")
    private Boder boder;

    @ApiModelProperty(value = "使用优惠券的订单号")
    @Transient
    private String ordernum;
}
